{% extends "flights/layout.html"%}

{% block content %}

<h1>
    flight: {{ flight.id }}
</h1>
<li>
    origin: <b>{{ flight.origin }}</b>
</li>
<li>
    destination: <b>{{ flight.destination }}</b>
</li>
<li>
    duration: <b>{{ flight.duration }}</b>
</li>

<h2>
    Passengers:
</h2>

{% for passenger in passengers %}
<li>
    {{ passenger }}
</li>
{% empty %}
<li>
    NO passenger
</li>
{% endfor %}

<h2>Add Passenger</h2>

<form action="{% url 'flights:book' flight.id %}" method="post">
    <!-- 身份验证，解决跨域 -->
    {% csrf_token%}
    <select name="passenger">
        {% for passenger in non_passengers %}
        <option value="{{ passenger.id }}">
            {{ passenger }}
        </option>
        {% endfor %}
    </select>
    <input type="submit">
</form>


<a href="{% url 'flights:index' %}">Back to Flights List</a>

{% endblock %}
